//
//  MXCommentsCell.m
//  CatchBear
//
//  Created by 王启颖 on 2018/12/10.
//  Copyright © 2018年 王启颖. All rights reserved.
//

#import "MXCommentsCell.h"

@interface MXCommentsCell ()
@property (weak, nonatomic) IBOutlet UIButton *commentsUser_btn;
@property (weak, nonatomic) IBOutlet UILabel *commentsUserName_lbl;
@property (weak, nonatomic) IBOutlet UILabel *commentsInfo_lbl;
@property (weak, nonatomic) IBOutlet UILabel *commentsTime_lbl;

@end
@implementation MXCommentsCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
    [self initCustomerControls];
}

- (void)initCustomerControls {
    
    [self.commentsUser_btn changeCornerRadius:self.commentsUser_btn.height/2];
}


-(void)setModel:(MXCommentsModel *)model{
    _model = model;
    
    self.commentsUserName_lbl.text = model.user.user_nickname;
    self.commentsInfo_lbl.text = [NSString stringWithFormat:@"%@",model.comments_info];
    [self.commentsUser_btn sd_setBackgroundImageWithURL:[NSURL URLWithString:model.user.user_headimg] forState:UIControlStateNormal];
    NSString *commentstime = [model.comments_time stringValue];
    self.commentsTime_lbl.text = [[commentstime substringToIndex:commentstime.length - 3] changeToDateWithDateFormatter:@"YYYY-MM-dd HH:mm"];
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}


+ (instancetype)cellWithTableView:(UITableView *)tableView {
    
    MXCommentsCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
    if (!cell) {
        cell = NSbunleloadNibName(@"MXCommentsCell");
    }
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    tableView.separatorStyle=UITableViewCellSeparatorStyleNone;
    
    return cell;
}


@end
